package com.dxy.dxyuser.controller;


import com.dxy.dxycommon.VO.ResultVO;
import com.dxy.dxycommon.utils.ResultVOUtil;
import com.dxy.dxyuser.DO.UserInfo;
import com.dxy.dxyuser.service.UserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserInfoService userInfoService;

    /**
     * 用户列表
     *
     * @param username
     * @param phone
     * @param start
     * @param end
     * @param pageSize
     * @param limit
     * @return
     */
    @RequestMapping(value = "/list")
    public ResultVO newlist(@RequestParam("username") String username,
                            @RequestParam("phone") String phone,
                            @RequestParam("start") String start,
                            @RequestParam("end") String end,
                            @RequestParam("pageSize") Integer pageSize,
                            @RequestParam("limit") Integer limit) {
        Page<UserInfo> list = userInfoService.findUsersNew(username, phone, start, end, pageSize, limit);
        return ResultVOUtil.success(list);
    }

    /**
     * 用户删除
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/delete")
    public ResultVO deleteUser(@RequestParam("id") String id) {
        userInfoService.deleteUser(id);
        return ResultVOUtil.success();
    }


}
